






<div class="admin-biaogelist">

    <div class="listbiaoti am-cf">
        <ul class="am-icon-flag on">任务管理</ul>

        <dl class="am-icon-home" style="float: right;">当前位置： 首页 > <a href="#">任务管理</a></dl>

        <!--<dl>
          <button type="button" class="am-btn am-btn-danger am-round am-btn-xs am-icon-plus" > 补充线订单</button>
        </dl>-->
        <!--这里打开的是新页面-->

    </div>

    <div class="fbneirong" id="dphjtbox">

         <div id="dphjt">
             <div class="hang">
                 <el-form ref="form" :model="form" >
                     <el-form-item label="用户名:" prop="username" class="itemInput" label-width="80px">
                         <el-input v-model="form.username" placeholder="请输入用户名"/>
                     </el-form-item>

                     <el-form-item label="商铺名:" prop="shop_name" class="itemInput" label-width="80px">
                         <el-input v-model="form.shop_name" placeholder="请输入商铺名"/>
                     </el-form-item>

                     <el-form-item label="ID:" prop="id" class="itemInput" label-width="80px">
                         <el-input v-model="form.id" placeholder="请输入ID"/>
                     </el-form-item>


                     <el-form-item label-width="80px" label="开始时间:" class="itemdate"  prop="date">
                         <el-date-picker style="width: 140px"
                                         v-model="form.date1"
                                         type="date"
                                         placeholder="选择日期"
                                         value-format="yyyy-MM-dd"
                         >
                         </el-date-picker>
                     </el-form-item>

                     <el-form-item label-width="80px" label="结束时间:" class="itemdate"  prop="date">
                         <el-date-picker style="width: 140px"
                                         v-model="form.date2"
                                         type="date"
                                         placeholder="选择日期"
                                         value-format="yyyy-MM-dd"
                         >
                         </el-date-picker>
                     </el-form-item>

                     <el-form-item label-width="60px" label="类型:" class="sourcedate"  prop="source">
                         <el-select  style="width:100px" v-model="form.status" placeholder="状态" claer>
                             <el-option

                                     key=""
                                     label="全部"
                                     value="">
                             </el-option>
                             <el-option
                                     v-for="(value,key) in select.status"
                                     :key="key"
                                     :label="value"
                                     :value="key">
                             </el-option>
                         </el-select>
                     </el-form-item>
                     <el-form-item  class="itembtn" label-width="20px">
                         <el-button type="primary" size="small" @click="getdata">获取数据</el-button>
                     </el-form-item>
                 </el-form>

             </div>
             <div class="hang" style="margin: 5px 0px;">

                 <div style="width: 100%;float: left">
                     <div class="hang title"><span>任务列表</span></span>

                     </div>
                     <el-table v-loading="listLoading" :data="list.llly.list"
                               :row-style="{height:'20px'}"
                               :cell-style="{padding:'4px'}"
                               height="540px"
                               @sort-change="changeTableSort" element-loading-text="加载中"  fit highlight-current-row>
                         <el-table-column label="ID" prop="id"
                                          align="center">
                         </el-table-column>
                         <el-table-column label="日期" prop="addtime"
                                          align="center">
                         </el-table-column>
                         <el-table-column label="定时" prop="releasetime"
                                          align="center">
                         </el-table-column>
                         <el-table-column label="状态" prop=""
                                          align="center">
                             <template slot-scope="scope"  >
                                 <el-tag   :type="scope.row.status | statusFilter">{{select.status[scope.row.status]}}</el-tag>
                             </template>
                         </el-table-column>
                         <el-table-column label="类型" prop="type_h"
                                          align="center">
                             <template slot-scope="scope"  >
                                 <span v-if="scope.row.type_h==1">普通单</span>
                                 <span v-else>高留评</span>
                             </template>
                         </el-table-column>
                         <el-table-column label="主商品" prop="goods_name"
                                          align="center">
                         </el-table-column>
                         <el-table-column label="商家" prop="shop_name"
                                          align="center">
                         </el-table-column>
                         <el-table-column label="用户" prop="username"
                                          align="center">
                         </el-table-column>
                         <el-table-column label="本金" prop="money"
                                          align="center">
                         </el-table-column>
                         <el-table-column label="完成/总数量" prop="number"
                                          align="center">
                         </el-table-column>
                         <el-table-column label="数量" prop="each_single"
                                          align="center">
                         </el-table-column>


                         <el-table-column label="操作" align="center" width="180px">
                             <template slot-scope="scope"  >
                                 <el-button type="primary" size="small" v-if="scope.row.status==0?1:0" @click="setstatus(scope.row)">发布</el-button>
                                 <el-button type="primary" size="small" v-if="scope.row.status<4?1:0" @click="setstatus(scope.row)">废除</el-button>
                                 <el-button type="primary" size="small" v-if="scope.row.status>3?1:0"@click="setstatus(scope.row)">恢复</el-button>
                             </template>
                         </el-table-column>
                     </el-table>
                     <div class="hang pagination" >
                         <el-pagination background @current-change="current_change" layout="total,prev, pager, next"
                                        :page-size="this.pagesize" :total="list.llly.total"></el-pagination>
                     </div>
                 </div>




             </div>
         </div>



    </div>












    <div class="foods">
        <ul>
            版权所有@2015.
        </ul>
        <dl>
            <a href="" title="返回头部" class="am-icon-btn am-icon-arrow-up"></a>
        </dl>
    </div>




</div>

</div>




</div>


<!--<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>-->
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="<?php echo base_url() . 'public/business/'; ?>assets/js/polyfill/rem.min.js"></script>
<script src="<?php echo base_url() . 'public/business/'; ?>assets/js/polyfill/respond.min.js"></script>
<script src="<?php echo base_url() . 'public/business/'; ?>assets/js/amazeui.legacy.js"></script>


<!--[if (gte IE 9)|!(IE)]><!-->
<script src="<?php echo base_url() . 'public/business/'; ?>assets/js/amazeui.min.js"></script>
<!--<![endif]-->



</body>
</html>
<script>

    new Vue({
        el: '#dphjtbox',
        filters: {
            statusFilter(status) {
                const statusMap = {
                    0: 'gray',
                    1: 'success',
                    2: 'success',
                    3: 'info',
                    4: 'danger',
                };
                return statusMap[status]
            }
        },
        data() {
            return {
                dialogtable: true,
                dialogtablefenxi: false,
                tabletitelfenxi:"",
                listLoading: false,
                select:{
                    status:["未发布","已发布","已发布(1)","已完成(2)","已废除"]
                },
                form:{
                    id:"",
                    username:"",
                    shop_name:"",
                    date1:"",
                    date2:"",
                    status:"",
                    page:1,
                },
                type:"line",
                list:{
                    productInfo:null,
                    gjclist:{
                        currpage:1,
                        list:[],
                        total: 0
                    },
                    llly:{
                        currpage:1,
                        list:[],
                        total: 0
                    },
                    fenxi:{
                        currpage:1,
                        list:[],
                        total:0
                    },

                },
                currpage: 1,
                pagesize: 10,
                tabletitel: "",


            }
        },
        created(){
            this.getdata()
        },

        methods: {

            getdata(){
                let post=this.form;
                let that=this;
                var url = "<?php echo base_url(); ?>/Customer/gettasklist/2/1";
                $.ajax({
                    url:url ,
                    type: "POST",
                    dataType: "json",
                    data: post,
                    success: function (res) {
                        if (res.code != 0) {
                            that.$message({
                                message: res.msg,
                                type: 'warning',
                                offset: 300,
                                duration: 1500
                            });
                        }else{
                            that.list.llly.list=res.list;
                            that.list.llly.total=res.count;
                        }
                    }
                })


            },
            current_change(currentPage) {
                this.form.page = currentPage;
                this.getdata();
            },

            setstatus(row){
                var text="立即发布";
                let status=1;
                if(row.status<4){
                    text='废除';
                    status=4
                }
                if(row.status==0){
                    text='今日发布';
                    status=1;
                }
                if(row.status>3){
                    text='恢复';
                    status=0
                }

                this.$confirm('此操作将'+text+'该任务, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.sendchange(row.id,status);
                }).catch(() => {

                });
            },

            sendchange(id,status){
                let post={
                    id:id,
                    status:status
                };
                let that=this;
                var url = "<?php echo base_url(); ?>/Customer/changeStatus";
                $.ajax({
                    url:url ,
                    type: "POST",
                    dataType: "json",
                    data: post,
                    success: function (res) {
                        if (res.code != 0) {
                            that.$message({
                                message: res.msg,
                                type: 'warning',
                                offset: 300,
                                duration: 1500
                            });
                        }else{
                            that.$message({
                                message:"设置成功",
                                type: 'success',
                                offset: 300,
                                duration: 1500
                            });
                          that.getdata(1);
                        }
                    }
                })
            }
        }
    })
</script>

<style>
    #dphjt input{
        width: 100%;
    }
    #dphjt .itemInput {
        width: 240px;
        float: left;
    }
    #dphjt .itemdate {
        width: 240px;
        float: left;
    }
    #dphjt .itembtn {
        width: 120px;
        float: left;
    }
    #dphjt .sourcedate {
        width: 150px;
        float: left;
    }


    #dphjt .title{
        border-left: solid 2px #5a5abf;
    }
    #dphjt .title> span:first-child{
        margin-left: 10px;
        font-weight: 700;
    }

    .hang {
        width: 100%;
        height: auto;
    }
</style>
